package com.monitor.web.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.monitor.web.dal.MobileNumberCodeDO;
import com.monitor.web.mapper.MobileNumberCodeDOMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author tanlian
 * @Date 2018/12/29 13:49
 * @Desc
 */
@Service
public class MybatisPageHelper {

    @Autowired
    private MobileNumberCodeDOMapper mobileNumberCodeDOMapper;

    public List<MobileNumberCodeDO> getList(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum, pageSize);

        List<MobileNumberCodeDO> list = mobileNumberCodeDOMapper.selectAll();
        PageInfo<MobileNumberCodeDO> pageInfo = new PageInfo<>(list);

        List<MobileNumberCodeDO> pageList = pageInfo.getList();
        return pageList;
    }

    public Object get(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum, pageSize,"CREATED_AT");

        List<MobileNumberCodeDO> list = mobileNumberCodeDOMapper.selectAll();
        PageInfo<MobileNumberCodeDO> pageInfo = new PageInfo<>(list);

        List<MobileNumberCodeDO> pageList = pageInfo.getList();
        return pageInfo;
    }
}
